package com.lhk.springbootmongodb.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

@Document(collection = "comment")
@CompoundIndex( def = "{'userid': 1, 'nickname': -1}")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Comment implements Serializable {

    @Id
    //主键
    private String id;
    @Field("content")
    //评论内容
    private String content;
    //发布日期
    private Date publishtime;
    @Indexed
    //评论者ID
    private String userid;
    //名字
    private String nickname;
    //时间
    private LocalDateTime createdatetime;
    //点赞数
    private Integer likenum;
    //回复数
    private Integer replynum;
    //状态
    private String state;
    //上级ID
    private String parentid;

    private String articleid;
}
